package WaiBao;

import java.util.Arrays;

public class LuJingRu {
    public static void main(String[] args) {
        String[] name = {"李凯凯(班长)","王思琪(副班长)", "小李(学习委员)","孔祥月(组织委员)", "王俊丽", "郭俊良", "李俊杰", "王志田", "闫志广", "黄启红", "李凯", "李昊天",
                "张柏芝", "林青霞", "林梦", "黄广招", "王迅", "李宁", "花木兰", "李白", "孙宝树", "周仁义", "李富贵", "张规财", "巴旦木", "芭蕉", "桂皮", "香叶",
                "张晨晨", "卢京茹(学生)"};//考生本人:卢京茹(学生)
        int[] age = {18, 19, 21, 18, 19, 21, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 19, 18, 19, 19, 19, 20, 20, 20, 18, 20, 18, 18, 20};//最后一位：考生年龄:20

        double[] fight1 = {87, 72, 89, 90, 69, 67, 78, 89, 85, 80, 91, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 92, 65, 75, 74, 90, 74, 85, 95};
        double[] fight2 = {74, 85, 94, 76, 78, 77, 74, 69, 94, 70, 90, 77, 76, 95, 65, 65, 76, 99, 66, 98, 75, 70, 94, 84, 75, 85, 94, 74, 81, 95};
        double[] fight3 = {84, 76, 84, 85, 77, 66, 79, 69, 80, 83, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 69, 95, 76, 84, 73, 71, 88, 96};

        double kouxiang1;//代表每个学生的总分
        double kouxiang2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            kouxiang1 = fight1[i] + fight2[i] + fight3[i];
//            kouxiang2 = (kouxiang1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + kouxiang1);
//            System.out.println(name[i] + "的平均分为:" + kouxiang2);
//        }


        double xue1 = 0, xue2 = 0;
        double[] jaijia = new double[30];
//        for (int i = 0; i < 30; i++) {
//            xue1= fight1[i] + fight2[i] + fight3[i];
//            xue2 = (xue1 * 1.0) / 3;
//            jaijia[i] = xue2;
//        }
//
//        for (int i = 0; i < jaijia.length - 1; i++) {
//            for (int j = 0; j < jaijia.length - i - 1; j++) {
//                if (jaijia[j] < jaijia[j + 1]) {
//                    double tep =jaijia[j];
//                    jaijia[j] = jaijia[j + 1];
//                    jaijia[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(jaijia[i]);
//        }


        double xufang1 = 0, xufang2 = 0, xufang3 = 0;//计算每门课的平均分
        double shu1 = 0, shu2 = 0, shu3 = 0;//计算每门课标准差
        double yanjing1 = 0, yanjing2 = 0,  yanjing3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <fight1.length; i++) {
            he += fight1[i];
        }
        xufang1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + xufang1);
        double Sum = 0;
        for (int i = 0; i < fight2.length; i++) {
            Sum += fight2[i];
        }
        xufang2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + xufang2);
        double sum = 0;
        for (int i = 0; i < fight3.length; i++) {
            sum += fight3[i];
        }
        xufang3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" +xufang3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < fight1.length; i++) {
            c1 += (fight1[i] - xufang1) * (fight1[i] - xufang1);
        }
        shu1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + shu1);
        for (int i = 0; i < fight2.length; i++) {
            c2 += (fight2[i] - xufang2) * (fight2[i] - xufang2);
        }
        shu2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" +shu2);

        for (int i = 0; i <fight3.length; i++) {
            c3 += (fight3[i] - xufang3) * (fight3[i] - xufang3);
        }
        shu3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + shu3);
////
//
//
        Arrays.sort(fight1);
        Arrays.sort(fight2);
        Arrays.sort(fight3);
        yanjing1 = (fight1[14] +fight2[15]) * 1.0 / 2;
        yanjing2 = (fight2[14] + fight2[15]) * 1.0 / 2;
        yanjing3 = (fight3[14] + fight3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" +  yanjing1);
        System.out.println("物理化学的中位数为:" +  yanjing2);
        System.out.println("电子与电工技术的中位数为:" +  yanjing3);



    }
}
